package com.eddie.juc.cf;

import java.util.concurrent.CompletableFuture;

/**
 * @author Eddie
 * @date 2022/08/18 10:49
 **/
public class CompletableFutureApi3Demo {
    public static void main(String[] args) {
        //thenRun不需要上一个任务的返回值并且没有返回值所以join结果为null
        System.out.println(CompletableFuture.supplyAsync(() -> "resultA").thenRun(() -> {
        }).join());
        //thenAccept处理了上一个人物的返回值但是自身没有返回值所以join结果也是null
        System.out.println(CompletableFuture.supplyAsync(() -> "resultA").thenAccept(System.out::println).join());
        //thenApply收到了上一一个任务的结果并且有返回值，所以join结果为resultA	resultB
        System.out.println(CompletableFuture.supplyAsync(() -> "resultA").thenApply(r -> r + "\tresultB").join());
    }
}
